package au.com.handsunited.dao;

import java.io.Serializable;
import java.util.List;

/**
 * @author Arun Chandrasekhar
 *
 */
public interface GenericDAO<T, ID extends Serializable> {

	/**
	 * Persist the newInstance object into the database
	 * @param newInstance
	 * @return
	 */
	T create(T newInstance);

	/**
	 * Retrieve an object that was previously persisted to the database using
	 * the indicated id as primary key
	 * @param id
	 * @return
	 */
	T read(ID id);

	/**
	 * Save changes made to a persistent object
	 * @param transientObject
	 * @return
	 */
	T update(T transientObject);

	/**
	 * Remove an object from persistent storage
	 * @param persistentObject
	 */
	void delete(T persistentObject);

	/**
	 *
	 * @param id
	 * @param lock
	 * @return
	 */
	T findById(ID id, boolean lock);

	/**
	 *
	 * @return
	 */
    List<T> findAll();

    /**
     *
     * @param exampleInstance
     * @return
     */
    List<T> findByExample(T exampleInstance);

    /**
     *
     * @param exampleInstance
     * @param excludeProperty
     * @return
     */
    List<T> findByExample(T exampleInstance, String[] excludeProperty);


}
